package com.czxy.demo01;

/**
 * Created by hp on 2020/1/31.
 */
public class Test11 {
    public static void main(String[] args) {
        int oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5};
        int a = 0;
        for (int i = 0; i < oldArr.length; i++) {
            if (oldArr[i]==0){
                continue;
            }
            a++;
        }
        int newArr[] = new int[a];
        int b = 0;
        for (int i : oldArr) {
            if (i!=0){
                newArr[b]=i;
                b++;
            }
        }
        System.out.print("int newArr[]={");
        for (int i = 0; i < newArr.length; i++) {
            if (i==newArr.length-1){
                System.out.print(newArr[i]+"}");
                break;
            }
            System.out.print(newArr[i]+",");
        }
    }
}
